package J5_5;

import java.util.Scanner;

public class test {
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), x = in.nextInt();
        for (int i = 0; i < n; i++) {
            int cur = in.nextInt();
            if (cur > x) {
                x += gcd(cur ,x);
            } else {
                x += cur;
            }
        }
        System.out.println(x);
    }
    static int gcd(int a, int b) {
        if (b % a == 0) {
            return a;
        } else {
            return gcd(b % a, a);
        }
    }

    public int maxValue (int[][] grid) {
        int r = grid.length, l = grid[0].length;
        int[][] dp = new int[r + 1][l + 1];
        for (int i = 1; i <= r; i++) {
            for (int j = 1; j <= l; j++) {
                dp[i][j] = Math.max(dp[i-1][j], dp[i][j-1]) + grid[i-1][j-1];
            }
        }
        return dp[r][l];
    }


    public static void main2(String[] args) {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        while (t-- > 0) {
            int n = in.nextInt();
            String[] str = new String[n];
            for (int i = 0; i < n; i++) {
                str[i] = in.next();
            }
            if (isStr(str)) {
                System.out.println("Yes");
            } else  {
                System.out.println("No");
            }
        }
    }

    private static boolean isStr(String[] str) {
        int n = str.length;
        for (int i = 0, j = n - 1; i < j; i++, j--) {
                if (!containsSame(str[i],str[j])) {
                    return false;
                }
        }
        return true;
    }

    private static boolean containsSame(String s1, String s2) {
        if (s1.length() > s2.length()) {
            return containsSame(s2, s1);
        }
        for (int i = 0; i < s1.length(); i++) {
            if (s2.indexOf(s1.charAt(i)) >= 0) {
                return true;
            }
        }
        return false;
    }

    public static void main(String[] args) {

    }

}
